package com.lxiaodd.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.lxiaodd.model.Income;
import com.lxiaodd.service.IncomeService;

@WebServlet(name = "IncomeService", urlPatterns = {"/income"})
public class IncomeServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//super.doGet(req, resp);
		String openid = req.getParameter("openid");
		String type = req.getParameter("type");
		double money = Double.parseDouble(req.getParameter("money"));
		AVObject income=new Income();
		income.put("openid", openid);
		income.put("type", type);
		income.put("money", money);
		try {
			income.save();
			resp.getWriter().println(income.getObjectId());
		} catch (AVException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		/*resp.setContentType("text/html;charset=utf-8");
		resp.getWriter().print(openid);*/
	}

}
